﻿using System;
using System.Linq;
using LINQPad.OpenAccess.Helpers;

namespace LINQPad.OpenAccess.Services
{
    /// <summary>
    /// <see cref="IDataContextServices"/>
    /// </summary>
    public class DataContextServices : IDataContextServices
    {
        #region Public

        #region - Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="DataContextServices" /> class.
        /// </summary>
        /// <param name="schemaProvider">The schema provider.</param>
        /// <param name="initializationService">The initialization service.</param>
        /// <param name="settingsRepository">The settings repository.</param>
        /// <param name="userInteractionService">The user interaction service.</param>
        /// <param name="customMemberProviderFactory">The custom member provider factory.</param>
        /// <param name="connectionDescriptionProvider">The connection description provider.</param>
        public DataContextServices( IDataContextSchemaProvider schemaProvider
                                        , IDataContextInitializationService initializationService
                                        , IDataContextSettingsRepository settingsRepository
                                        , IDataContextUserInteractionService userInteractionService
                                        , IDataContextCustomMemberProviderFactory customMemberProviderFactory
                                        , IDataContextConnectionDescriptionProvider connectionDescriptionProvider )
        {
            Guard.ArgumentNotNull( schemaProvider, "schemaProvider" );
            Guard.ArgumentNotNull( initializationService, "initializationService" );
            Guard.ArgumentNotNull( settingsRepository, "settingsRepository" );
            Guard.ArgumentNotNull( userInteractionService, "userInteractionService" );
            Guard.ArgumentNotNull( customMemberProviderFactory, "customMemberProviderFactory" );
            Guard.ArgumentNotNull( connectionDescriptionProvider, "connectionDescriptionProvider" );

            this.SchemaProvider = schemaProvider;
            this.InitializationService = initializationService;
            this.SettingsRepository = settingsRepository;
            this.UserInteractionService = userInteractionService;
            this.CustomMemberProviderFactory = customMemberProviderFactory;
            this.ConnectionDescriptionProvider = connectionDescriptionProvider;
        }
        #endregion

        #endregion

        #region IDataContextServices Members

        /// <summary>
        /// Gets the connection description provider.
        /// </summary>
        /// <value>
        /// The connection description provider.
        /// </value>
        public IDataContextConnectionDescriptionProvider ConnectionDescriptionProvider { get; private set; }
        /// <summary>
        /// Gets the custom member provider factory.
        /// </summary>
        /// <value>
        /// The custom member provider factory.
        /// </value>
        public IDataContextCustomMemberProviderFactory CustomMemberProviderFactory { get; private set; }
        /// <summary>
        /// Gets the initialization service.
        /// </summary>
        /// <value>
        /// The initialization service.
        /// </value>
        public IDataContextInitializationService InitializationService { get; private set; }
        /// <summary>
        /// Gets the schema provider.
        /// </summary>
        /// <value>
        /// The schema provider.
        /// </value>
        public IDataContextSchemaProvider SchemaProvider { get; private set; }
        /// <summary>
        /// Gets the settings repository.
        /// </summary>
        /// <value>
        /// The settings repository.
        /// </value>
        public IDataContextSettingsRepository SettingsRepository { get; private set; }
        /// <summary>
        /// Gets the user interaction service.
        /// </summary>
        /// <value>
        /// The user interaction service.
        /// </value>
        public IDataContextUserInteractionService UserInteractionService { get; private set; }

        #endregion
    }
}
